<template>
  <ul>
    <li v-for="i in productArr">{{ i }}</li>
  </ul>
  <ul>
    <li v-for="i in 5">{{ i }}</li>
  </ul>
  <table border="1px">
    <tr>
      <th>序号</th>
      <th>名称</th>
      <th>价格</th>
      <th>库存</th>
      <th>功能</th>
    </tr>
    <tr v-for="(p,index) in productArr">
      <td>{{ index + 1 }}</td>
      <td>{{ p.title }}</td>
      <td>{{ p.price }}</td>
      <td>{{ p.num }}</td>
      <td>
        <button @click="del(index)">删除</button>
      </td>
    </tr>
  </table>
</template>

<script setup>
import {ref} from "vue";

let productArr = ref(
    [
      {title: '书', price: '12', num: '800'},
      {title: '笔', price: '12', num: '800'},
      {title: '包', price: '12', num: '800'}
    ]
);
const del = (index)=>{
  productArr.value.splice(index,1);
}
</script>

<style scoped>

</style>